<template>
	<!-- 招募详情页 -->
	<view class="content">
		<view class="recruit-top">
			    <view class="recruit-middle">
				    <image :src="itemData.userHeaderImage" @click="goOthershomepage(itemData.recruitId)"></image>
				    <text class="recruit-text1">{{itemData.userNickname}}</text>
				    <text class="recruit-text2">官方认证：{{itemData.authenticationSponsorName}}</text>
			    </view>
			    <view class="recruit-first">
				    <text class="first-txt1">[{{itemData.recruitClass}}]</text>
				    <text class="first-txt2">{{itemData.recruitName}}</text>
			    </view>
			    <view class="recruit-second">
				    <text>截止日期：{{itemData.recruitEndTime}}</text>
			    </view>
			    <view class="recruit-money">
				    <text>￥{{itemData.recruitPrice}}</text>
			    </view>
		    <!-- </view> -->
		    <view class="recruit-bottom">
			    <view class="bottom-top">
				    <image src="../../static/images/recruitNeed.png"></image>
			        <text>需求内容</text>
			    </view>
			    <view class="bottom-middle">
				    <text class="bottom-content">应幕条件</text>
					<text class="content">{{itemData.recruitCondition}}</text>
			    </view>
			    <view class="bottom-middle">
				    <text class="bottom-content">应幕福利</text>
					<text class="content">{{itemData.recruitWelfare}}</text>
			    </view> 
			    <!-- 轮播图 -->
		        <view class="banner img_con">
			        <image v-for="(item,index) in itemData.recruitImages" :src="item.recruitImage" :key="index" :class="imgClassObj"></image>
		        </view>
		    </view>
		    <view class="bottom_pay_con">
			    <button class="pay_btn" type="default" @click="goSign(itemData.recruitId)">立即报名</button>
		    </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				itemData:{},
			}
		},
		onNavigationBarButtonTap(){
			uni.navigateBack({
				
			})
		},
		methods: {
			goSign(id){
				this.$hasToken()
				uni.navigateTo({
				    url:'../sign/sign?bid='+id
				})
				this.$request('/comic-time/isSignUp',{
					recruitId:val,
				},
				'GET').then(res => {
					// console.log(res.data)
					// console.log(this.itemData)
					this.itemData.push(res.data)
					// console.log(this.itemData)
				})
				
				// const hasToken = ()=> {
				//     const token = uni.getStorageSync('token');
				//     if (token) {
				//         console.log(token);
				//         return true
				// 		uni.navigateTo({
				// 	        url:'../sign/sign?bid='+id
				//         })
				// 		this.$request('/comic-time/isSignUp',{
				// 			recruitId:val,
				// 		},
				// 		'GET').then(res => {
				// 			console.log(res.data)
				// 			console.log(this.itemData)
				// 			this.itemData.push(res.data)
				// 			console.log(this.itemData)
				// 		})
				//     }else{
				//         uni.reLaunch({
				//             url: '/pages/components/login/login'
				//         });
				//     }
				// }
			},
			goOthershomepage(id){
				uni.navigateTo({
					url:'/components/me/othershomepage?userId='+id
				})
			},
			//请求数据
			getDataList(val){
				this.$request('/comic-time/getRecruitById',{
					recruitId:val,
				},
				'GET').then(res => {
					// console.log(res.data)
					// console.log(this.itemData)
					this.itemData=res.data
					// console.log(this.itemData)
			    })
			},
		},
		onLoad(val) {
			// console.log(val)
		    this.getDataList(val.pid)
		},
		computed:{
			imgClassObj(){
				
				// console.log(recruitImages)
				
					const {recruitImages}=this.itemData
					// console.log(recruitImages)
					return {
					"img_item":recruitImages,//&&recruitImages.length>1,
					"img_item2":recruitImages&&recruitImages.length>1,
					"img_item3":recruitImages&&recruitImages.length>3
				
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '../recruit/recruit.scss'
</style>
